#!/usr/bin/python3
# -* - coding: UTF-8 -* -

import time
import requests
from utils import SetResult


def parse_to_timestamp(timeStr):
    try:
        timeArray=time.strptime(timeStr,'%Y-%m-%d %H:%M:%S') #按照对应的格式转换为时间数组time.strptime()
    except ValueError as e:
        try:
            timeArray = time.strptime(timeStr, '%Y-%m-%d')
        except ValueError as e:
            SetResult.set_fail('时间格式不符合预期,参数：{}'.format(timeStr))
    timeStamp=int(time.mktime(timeArray)) #转换成整形时间戳 time.mktime()
    return timeStamp


if __name__ == '__main__':
    pass